<?php

namespace App\Services\Setting;

use App\Services\ProjectValidate;

/**
 * 平台设置验证
 * Class ValidateSetting
 * @package App\Services\Setting
 */
class ValidateSetting extends ProjectValidate
{

    /**
     * 自定义子类初始化
     * @param array $initData
     * @return mixed
     */
    public function initValidate($initData = [])
    {
        if (!empty($initData['requiredId'])) {
            $this->rules['id']  = 'required|int|min:1';
        }
    }


    /**
     * @var array 验证规则集合
     */
    public $rules = [
        'id'            => 'int|min:1',
        'category_id'   => 'int|min:1',
        'name'          => 'string|min:s|max:50',
        'value'         => 'min:1',
        'action'        => 'min:2',
        'type'          => 'in:1,2,3,4',
        'order'         => 'int|min:1',
        'page'          => 'int|min:1',
        'listRows'      => 'integer|min:1|max:100'
    ];

    /**
     * @var array 当前验证错误信息
     */
    public $messages = [
    ];

    /**
     * @var array 上面规则中定义的 key 的名字
     */
    public $attributes = [
        'id'        => 'ID',
    ];
}